package org.example.evaluate.enums;

import java.math.BigDecimal;
import java.util.stream.Stream;

public enum Model {
    other_model(14, "其他版本", BigDecimal.valueOf(0.9)),
    A1786(15, "A1786", BigDecimal.valueOf(0.93)),
    A1661(16, "A1661", BigDecimal.valueOf(0.93)),
    A1780(17, "A1780", BigDecimal.valueOf(0.93)),
    A1660(18, "A1660", BigDecimal.valueOf(0.93)),
    A1586(64, "A1586", BigDecimal.valueOf(0.93)),
    A1589(65, "A1589", BigDecimal.valueOf(0.93)),
    gh(66, "官换机", BigDecimal.valueOf(0.86)),
    A1524(67, "A1524", BigDecimal.valueOf(0.93)),
    A1593(68, "A1593", BigDecimal.valueOf(0.93));

    private final Integer code;
    private final String name;
    private final BigDecimal kf;

    Model(Integer code, String name, BigDecimal kf) {
        this.code = code;
        this.name = name;
        this.kf = kf;
    }

    public Integer getCode() {
        return code;
    }

    public BigDecimal getKf() {
        return kf;
    }

    public static Model buildModel(Integer code) {
        return Stream.of(Model.values())
                .filter(v -> v.getCode() == code)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException(String.format("传入的型号码 [%s] 不正确", code)));
    }
}
